package com.ysd.servlet.admin;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.ysd.dao.impl.XinWenDaoImpl;
import com.ysd.entity.XinWen;
import com.ysd.util.BaseServlet;
import com.ysd.util.Result;

public class AdminXinWenServlet extends BaseServlet {
	
	/**
	 * 查询所有新闻
	 * localhost:8080/qiuxieshangcheng/adminXinWen?reqName=delXinWen
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	public void getXinWen(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		XinWenDaoImpl xwDao = new XinWenDaoImpl();//创建实现类对象
		List<XinWen> xwList=  xwDao.getXinWenList1();//查到得所有产品集合
		//发送Ajax请求 服务器基本都会返回json格式字符串
		
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		Gson gson = new Gson();
		String res=gson.toJson(xwList);
		 out.print(res);
		
		out.flush();
		out.close();
		
	}
	
	

}
